<template>
 <!-- 晨会、夕会 交付看板 -->
  <div class="board-content">
    <board-title title="交付" bgclass="bg-jf">
      <img slot="flagImg" class="flag-img" src="~@/assets/imgs/publicline/board/flag_jf.png" />
    </board-title>
    <van-loading v-if="isLoading" type="spinner" color="#1989fa" />
    <div v-else class="board-jf-info">
      <div class="board-jf-item">
        <div class="title"><img src="~@/assets/imgs/publicline/board/icon-yj.png" />移机</div>
        <div class="sub-title">当日值/当月累计</div>
        <div class="value" @click="openPeopleDetail('yj', info.YJ_VALUE, info.YJ_M_VALUE, info.YJ_HB)">{{ info.YJ_VALUE || 0 }}/{{ info.YJ_M_VALUE || 0 }}<span class="unit">户</span></div>
        <div class="percent-title">
          环比上月
          <span v-if="info.YJ_HB >= 0" class="percent up">
            {{ info.YJ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_up.png" />
          </span>
          <span v-else class="percent down">
            {{ info.YJ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_down.png" />
          </span>
        </div>
      </div>
      <div class="board-jf-item">
        <div class="title"><img src="~@/assets/imgs/publicline/board/icon-zj.png" />装机</div>
        <div class="sub-title">当日值/当月累计</div>
        <div class="value" @click="openPeopleDetail('zj', info.ZJ_VALUE, info.ZJ_M_VALUE, info.ZJ_HB)">{{ info.ZJ_VALUE || 0 }}/{{ info.ZJ_M_VALUE || 0 }}<span class="unit">户</span></div>
        <div class="percent-title">
          环比上月
          <span v-if="info.ZJ_HB >= 0" class="percent up">
            {{ info.ZJ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_up.png" />
          </span>
          <span v-else class="percent down">
            {{ info.ZJ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_down.png" />
          </span>
        </div>
      </div>
      <div class="board-jf-item">
        <div class="title"><img src="~@/assets/imgs/publicline/board/icon-xz.png" />修障</div>
        <div class="sub-title">当日值/当月累计</div>
        <div class="value" @click="openPeopleDetail('xz', info.XZ_VALUE, info.XZ_M_VALUE, info.XZ_HB)">{{ info.XZ_VALUE || 0 }}/{{ info.XZ_M_VALUE || 0 }}<span class="unit">户</span></div>
        <div class="percent-title">
          环比上月
          <span v-if="info.XZ_HB >= 0" class="percent up">
            {{ info.XZ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_up.png" />
          </span>
          <span v-else class="percent down">
            {{ info.XZ_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_down.png" />
          </span>
        </div>
      </div>
      <div class="board-jf-item">
        <div class="title"><img src="~@/assets/imgs/publicline/board/icon-2Ijf.png" />2I交付</div>
        <div class="sub-title">当日值/当月累计</div>
        <div class="value" @click="openPeopleDetail('jf2i', info.JF_2I_VALUE, info.JF_2I_M_VALUE, info.JF_2I_HB)">{{ info.JF_2I_VALUE || 0 }}/{{ info.JF_2I_M_VALUE || 0 }}<span class="unit">户</span></div>
        <div class="percent-title">
          环比上月
          <span v-if="info.JF_2I_HB >= 0" class="percent up">
            {{ info.JF_2I_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_up.png" />
          </span>
          <span v-else class="percent down">
            {{ info.JF_2I_HB }}%
            <img src="~@/assets/imgs/publicline/index/arrow_down.png" />
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import boardTitle from '@/views/components/publicline/board/title.vue'
import { morningDayDeliver } from '@/api/publicline/board.js'

export default {
  components: { boardTitle },
  data() {
    return {
      isLoading: true,
      info: {},
      queryParams: {}
    }
  },
  methods: {
    // 晨会看板-日看板-交付
    async getMorningDayDeliver(params) {
      this.isLoading = true
      this.queryParams = params
      const res = await morningDayDeliver(params)
      const { result, success } = res
      if (success) {
        this.info = result[0] || {}
        this.isLoading = false
      }
    },
    openPeopleDetail(type, value = 0, mvalue = 0, hb = 0) {
      this.$open.call(this, '/publicline/board/personal',
        {
          ...this.queryParams,
          type: type,
          flag: 'morning',
          value, mvalue, hb
        }
      )
    }
  }
}
</script>
<style lang="less" scoped>
.board-jf-info {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0 16px;
  .board-jf-item {
    width: 45%;
    padding: 12px 0 8px 12px;
    background: #FCFBFA;
    margin-bottom: 10px;
    .title {
      display: flex;
      align-items: center;
      img {
        width: 14px;
        margin-right: 6px;
      }
    }
    .sub-title {
      font-size: 12px;
      color: #999;
      margin-top: 6px;
    }
    .value {
      font-size: 24px;
      color: #FFAB4D;
      margin: 2px 0;
    }
    .unit {
      font-size: 14px;
    }
    .percent-title {
      font-size: 12px;
      color: #999;
      .percent {
        padding-left: 10px;
      }
      .up {
        color: #FF6024;
      }
      .down {
        color: #40BB3F;
      }
      img {
        width: 11px;
      }
    }
  }
}
</style>
